/**
 * declare 表头表单mixins  表单回车等事件
 */
export default {
    data () {
        return {
            // 监听表单
            declareWatchs: Object.freeze([
                { key: 'manualNo',
                    handler: (v, o) => {
                        this.handleDisabledManualNo(v, o)
                    },
                    options: {
                        immediate: true
                    }
                }
            ])
        }
    },
    methods: {
        checkDeclareMainField (key, cb) {
            this.validateField('declareForm', key, cb)
        },
        // 根据备案号是否禁用商品的备案序号
        handleDisabledManualNo (v, o) {
            const x = v ? (String(v).length <= 0) : true
            const y = o ? (String(o).length <= 0) : true
            if (x || y) {
                this.$nextTick(() => {
                    if (this.$refs.goodsForm) {
                        const flag = !!this.form.isConfirm || x
                        this.$refs.goodsForm.setDisabled('contrItem', flag)
                    }
                })
            }
        }
    }
}
